# 设置 CMake 版本要求
cmake_minimum_required(VERSION 3.10)

# 设置项目名称和版本
project(RUI_OMNI VERSION 1.0)

# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(GCC_CLANG_WARNINGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_CLANG_WARNINGS}")

# 包含头文件目录
include_directories(inc BToolbox CMSIS/Core/Inc CMSIS/DSP/Inc/dsp CMSIS/DSP/Inc CMSIS/DSP/PrivateInclude)

add_definitions(

        -DARM_MATH_CM7
        -D__FPU_USED=1U
        -D__FPU_PRESENT=1U
        -DARM_MATH_MATRIX_CHECK
        -DARM_MATH_ROUNDING
)

# 获取源文件列表
file(GLOB_RECURSE SOURCES "src/*.*" "BToolbox/*.*"
        "CMSIS/DSP/Src/BasicMathFunctions/BasicMathFunctions.c"
        "CMSIS/DSP/Src/BayesFunctions/BayesFunctions.c"
        "CMSIS/DSP/Src/CommonTables/CommonTables.c"
        "CMSIS/DSP/Src/ComplexMathFunctions/ComplexMathFunctions.c"
        "CMSIS/DSP/Src/ControllerFunctions/ControllerFunctions.c"
        "CMSIS/DSP/Src/FastMathFunctions/FastMathFunctions.c"
        "CMSIS/DSP/Src/FilteringFunctions/FilteringFunctions.c"
        "CMSIS/DSP/Src/InterpolationFunctions/InterpolationFunctions.c"
        "CMSIS/DSP/Src/MatrixFunctions/MatrixFunctions.c"
        "CMSIS/DSP/Src/QuaternionMathFunctions/QuaternionMathFunctions.c"
        "CMSIS/DSP/Src/StatisticsFunctions/StatisticsFunctions.c"
        "CMSIS/DSP/Src/SupportFunctions/SupportFunctions.c"
        "CMSIS/DSP/Src/SVMFunctions/SVMFunctions.c"
        "CMSIS/DSP/Src/TransformFunctions/TransformFunctions.c"
        "CMSIS/DSP/Src/WindowFunctions/WindowFunctions.c"
)

# 添加可执行文件
add_executable(RUI_OMNI ${SOURCES})

# 根据编译类型添加定义
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    add_definitions(-DRUI_BUILD_DEBUG)
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
    add_definitions(-DRUI_BUILD_RELEASE)
endif ()

# 根据静态编译设置添加定义和链接选项
if (BUILD_STATIC)
    set(CMAKE_BUILD_TYPE Release)
    add_definitions(-DRUI_BUILD_STATIC)
    target_link_libraries(RUI_OMNI PRIVATE
            -static-libgcc -static-libstdc++
            -Wl,--whole-archive -lpthread -Wl,--no-whole-archive
            -static
    )
else ()
    target_link_libraries(RUI_OMNI PRIVATE
            pthread
    )
endif ()


